<template>

  <div>
      <filtrate></filtrate>
      <list :date="data" 
      v-if="aaa" 
      @sc='sc'
      @sj='sj'
      @bj='bj'
      @fanye='fanye'
      ></list>
      <xinxitianji @fanhui='bj' :item='bianj' v-else></xinxitianji>
  </div>
</template>

<script>
import list from './list.vue';
import xinxitianji from './xinxitianji.vue';
import http from '../../../http/http'
import filtrate from '../../../components/lef_nav/filtrate.vue';
export default {
  data() {
    return {
      aaa: true,
      data:[],
      bianj : null
    }
  },
  methods:{
    // 删除
    
      
      sc(value){
        if (confirm("确认删除么")) {
          http.dele({
            name:'1',
            id:value
          })
          this.data = this.data.filter(res=> res.id != value)
        }
    },
    // 编辑
    bj(value){
      this.bianj = value
      this.aaa = !this.aaa
    },
    // 上架
    sj(value){
      this.$message('上架成功');
    },
    // 翻页
    fanye(value){
      http.get(value)
      .then(res=>{
        this.data = res.data 
      })
    }
  },
   created(){
    //  开始获取首页数据
    http.get(0)
    .then(res=>{
       this.data = res.data 
    })
        
  },
 components:{list,xinxitianji,filtrate}
};
</script>

<style lang="scss" scoped>

</style>